package com.javatiaocao.myblog.mapper;

import com.javatiaocao.myblog.model.Article;
import com.javatiaocao.myblog.model.ArticleLikesRecord;
import com.javatiaocao.myblog.model.Categories;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArticleMapper {
        Article findArticleById(Integer id);

        @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
        Integer publishArticle(Article article);

        List<Article> selectArticleWithPage();

        void deleteArticleById(Integer id);

        Integer countArticle();

        void updateArticleById(Article article);


        List<Categories> selectCategoriesList();

        Categories selectCategoriesByName(String categoryName);

        void createCategories(String categoryName);

        Article getArticleByid(Integer id);

        Article getArticleByArticleTitle(String articleTitle);

        void deleteCategories(String categoryName);

        int findArticleByCAtegory(String articleType);

        void updateLastNextId(@Param("lastOrNextStr") String lastOrNextStr,
                              @Param("updateId") long updateId,
                              @Param("articleId")long articleId);

        List<Article> selectArticleByNameWithPage(String userName);

        List<Article> selectArticleByPhone(String phone);

        List<ArticleLikesRecord> selectArticleByAId(long idList);

        void readAllById(long articleId);

        int selectArticleNumByCategory(String articleCategories);

        Article getArticleDetailByArticleId(long articleId);

    List<Article> getCategoryArticle(String category);
}
